<template>
	<view class="index">
		<musichead title="网易云音乐" :icon="false" color="white"></musichead>
		<view class="container">
			<scroll-view scroll-y="true">
				<view class="index-search" @tap="handtoSearch">
					<text class="iconfont iconsearch" ></text>
					<input type="text" placeholder="搜索歌曲" />
				</view>
				<view class="index-list-item" v-for="(item,index) in list" :key="index"
					@tap="handleToList(item.listId)">
					<view class="index-list-img">
						<image :src="item.coverImgUrl+'?param=110y110'" mode=""></image>
						<text>{{item.updateFrequency}}</text>
					</view>
					<view class="index-list-text">
						<view v-for="(track,index) in item.tracks" :key="index">{{index+1}}. {{track.first}} -
							{{track.second}}
						</view>
					</view>
				</view>
				<view class="txt">
					<a href="https://music.163.com/" style="text-decoration: none">仅测试非商用</a>
				</view>
			</scroll-view>
		</view>

	</view>

</template>

<script>
	import musichead from '@/components/muics/muics.vue';
	import '@/common/iconfont.css';
	import {
		topList
	} from '../../common/api.js'
	export default {
		data() {
			return {
				list: []
			}
		},
		components: {
			musichead
		},
		onLoad() {
			// then接受参数
			topList().then(res => {
				this.list = res
			})
			// console.log(topList());
		},
		methods: {
			handleToList(listId) {
				uni.navigateTo({
					url: '/pages/list/list?listId=' + listId
				})
			},
			handtoSearch() {
				uni.navigateTo({
					url: '/pages/search/search'
				})
			}
		},


	}
</script>


<style scoped>
	.txt {
		text-align: center;
		font-size: 26rpx;
		color: #282C35;
	}

	.txt a {
		color: #282C35;
	}

	.index-search {
		display: flex;
		align-items: center;
		height: 70rpx;
		margin: 70rpx 30rpx 30rpx 30rpx;
		background: #f7f7f7;
		border-radius: 50rpx;
	}

	.index-search text {
		font-size: 26rpx;
		margin-right: 26rpx;
		margin-left: 28rpx;
	}

	.index-search input {
		font-size: 28rpx;
		flex: 1;
	}

	.index-list {
		margin: 0 30rpx;
	}

	.index-list-item {
		display: flex;
		margin-bottom: 34rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
	}

	.index-list-img {
		width: 212rpx;
		height: 212rpx;
		position: relative;
		border-radius: 4%;
		overflow: hidden;
		margin-right: 22rpx;
	}

	.index-list-img image {
		width: 100%;
		height: 100%;
	}

	.index-list-img text {
		position: absolute;
		left: 12rpx;
		bottom: 16rpx;
		color: white;
		font-size: 20rpx;
	}

	.index-list-text {
		font-size: 24rpx;
		line-height: 66rpx;
		flex: 1;
	}

	.index-list-text view {

		word-break: break-all;
		text-overflow: ellipsis;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		display: -webkit-box;
		overflow: hidden;
		margin-right: 20rpx;
	}
</style>
